package cn.micro.eye.web;

import cn.micro.eye.commons.auth.PreAuth;
import cn.micro.eye.commons.oss.QiNiuOssService;
import cn.micro.eye.commons.sms.AliYunSmsService;
import cn.micro.eye.model.vo.OssTokenVO;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@PreAuth
@Validated
@RestController
@RequestMapping("oss")
public class OssController {

    @Resource
    private QiNiuOssService qiNiuOssService;
    @Resource
    private AliYunSmsService aliYunSmsService;

    @RequestMapping(value = "upload-token", method = RequestMethod.GET)
    public OssTokenVO uploadToken() {

        return new OssTokenVO(qiNiuOssService.getUploadToken(), qiNiuOssService.getAccessUrl());
    }

    @RequestMapping(value = "send", method = RequestMethod.GET)
    public Boolean send() throws Exception {
        return aliYunSmsService.send("BUY", "15828252029", "李景枫", "电脑", "10001");
    }

}
